// easyui实现自定义simpleData加载
$.fn.tree.defaults.loadFilter = function (data) {
    var opt = $(this).data().tree.options; // 整个tree的dom对象
    var idField, textField, parentField, iconField;
    if (opt.parentField) {
        idField = opt.idField || 'id';
        textField = opt.textField || 'text';
        parentField = opt.parentField;
        iconField = opt.iconField || 'iconCls';

        var i,l,
            treeData = [],
            tmpMap = [];

        for (i = 0, l = data.length; i < l; i++) {
            tmpMap[data[i][idField]] = data[i];
        }

        for (i = 0, l = data.length; i < l; i++) {
            if (tmpMap[data[i][parentField]] && data[i][idField] !== data[i][parentField]) {
                if (!tmpMap[data[i][parentField]]['children']) {
                    tmpMap[data[i][parentField]]['children'] = [];
                }
                data[i]['text'] = data[i][textField];
                data[i]['iconCls'] = data[i][iconField];
                tmpMap[data[i][parentField]]['children'].push(data[i]);
            } else {
                data[i]['text'] = data[i][textField];
                data[i]['iconCls'] = data[i][iconField];
                treeData.push(data[i]);
            }
        }
        return treeData;
    }
    return data;
};